<?php

//

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CoreServiceApp
 *
 * @author jianfeng
 */
class BilynAdminApp extends BServiceApp {

    public function addRolesToService($service) {
        
    }  

    public function registerAppRoles() {
        
    }

    public function registerApp($appClass) {

   //     $this->checkAccess(__METHOD__);

        $currentClass = get_class();

        if ($appClass == $currentClass)
            $rApp = $this;
        else
            $rApp = new $appClass(null, false);

       // $meta0 = $rApp->registerAppMeta();
        $meta = $rApp->getRegisterAppMeta();

        $db = $this->getDbAdapter();

        $meta['appclass'] = $appClass;

        $appId = $db->registerServiceApp($meta);

        $app = BServiceApp::getInstanceById($appId);

        $app->register();
        
        return  $appId;
    }

    public function registerSystemApps() {

        $id = $this->getDbAdapter()->getServiceAppId('BServiceEngine');

        if ($id == null || $id == FALSE || $id <= 0) {
            $this->registerApp('BServiceEngine');
            $this->registerApp('BilynAdminApp');
            $this->registerApp('BPersonalApp');
            //     $this->registerApp('BPersonalMessageApp');
        }
    }
    
    public function configApp($name)
    {
        $this->checkAccess(__METHOD__);        
    }

    //call when update operations
    public function registerAppOperations() {
        
   //     $this->checkAccess(__METHOD__);
        
        $config = $this->getConfigManager();
        $regOpps = $config->getConfig('registerOperations');

       // $oppRegisterApp = array('name' => 'RegisterApp', 'function' => 'registerApp', 'data' => array('screen' => 'BScreenRegisterOperation'));

        return $regOpps;
    }

}

?>
